import React from 'react';
import {List, message} from 'antd';
import Icon from './index';
import {Tool} from '../../utils';

/**
 * 图标的Demo
 */
export default class Test extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <List
        grid={{
          column: 8,
          gutter: 16
        }}
        dataSource={Icon.types}
        renderItem={(item) => (
          <List.Item style={{background: '#eee', textAlign: 'center'}}>
            <div>
              <a onClick={() => this.click(item)}>
                <Icon type={item} style={{fontSize: 40, color: '#F77'}} />
              </a>
            </div>
            <span> {item}</span>
          </List.Item>
        )}
      />
    );
  }

  /**
   * 点击图标
   * @param item
   */
  click(item) {
    let text = `<Icon type='${item}' style={{fontSize: 40, color: '#F77'}} />`;
    Tool.copyText(text);
    message.success(text);
  }
}
